//
//  CourseDetailsCatalogTableViewCell.m
//  ZFPlayer_Example
//
//  Created by 洪欣 on 2019/1/4.
//  Copyright © 2019年 紫枫. All rights reserved.
//

#import "CourseDetailsCatalogTableViewCell.h"
#import <UIImageView+WebCache.h>

@interface CourseDetailsCatalogTableViewCell ()
@property (weak, nonatomic) IBOutlet UIImageView *picView;
@property (weak, nonatomic) IBOutlet UILabel *courseNameLb;
@property (weak, nonatomic) IBOutlet UILabel *courseTimeLb;
//@property (nonatomic, strong) UIImageView *signImageView;/**展示类型 图片 音频  视频*/
@property (weak, nonatomic) IBOutlet UIImageView *typeIcon;

@end

@implementation CourseDetailsCatalogTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];

    self.picView.contentMode = UIViewContentModeScaleAspectFit;
    
    self.picView.layer.cornerRadius = 5;
    self.picView.layer.masksToBounds = YES;
//    self.courseTimeLb.font = [UIFont systemFontOfSize:12*ScaleX];
//    self.courseNameLb.font = [UIFont systemFontOfSize:14*ScaleX];
}

- (void)setModel:(CourseDetailsCourseHourOutputDTODataModel *)model {
    _model = model;
    NSString *urlString = [NSString stringWithFormat:@"%@%@",Public_URL,model.videoImage];
    NSLog(@"%@",urlString);
    [self.picView sd_setImageWithURL:[NSURL URLWithString:urlString]];
    self.courseNameLb.text = model.hourName;
    
//    self.courseTimeLb.frame.size.width = 49;
    self.courseNameLb.textColor = model.selected ? [UIColor colorWithRed:233.f/255.f green:84.f/255.f blue:18.f/255.f alpha:1] : [UIColor colorWithRed:102.f/255.f green:102.f/255.f blue:102.f/255.f alpha:1];
    self.courseTimeLb.textColor = model.selected ? [UIColor colorWithRed:233.f/255.f green:84.f/255.f blue:18.f/255.f alpha:1] : [UIColor colorWithRed:102.f/255.f green:102.f/255.f blue:102.f/255.f alpha:1];
#pragma mark - 滚动视图内部控件 hourType 0 视频 1 音频 2图片
    if ([model.hourType integerValue]==2) {
        self.typeIcon.image = model.selected?[UIImage imageNamed:@"wk_pic_s"]:[UIImage imageNamed:@"wk_pic"];
        [self.typeIcon remakeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-15*ScaleX);
            make.centerY.mas_equalTo(self.contentView);
            make.size.mas_equalTo(CGSizeMake(16*ScaleX, 16*ScaleX));
        }];
        self.courseTimeLb.hidden = YES;
    }else if ([model.hourType integerValue]==1){
        self.courseTimeLb.hidden = NO;
        self.typeIcon.image = model.selected?[UIImage imageNamed:@"wk_audio_s"]:[UIImage imageNamed:@"wk_audio"];
        [self.courseTimeLb remakeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-15*ScaleX);
            make.centerY.mas_equalTo(self.contentView);
            make.size.mas_equalTo(CGSizeMake(49*ScaleX, 15*ScaleX));
        }];
        [self.typeIcon remakeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(self.courseTimeLb.mas_left).mas_equalTo(-6*ScaleX);
            make.centerY.mas_equalTo(self.contentView);
            make.size.mas_equalTo(CGSizeMake(16*ScaleX, 16*ScaleX));
        }];
    }else if([model.hourType integerValue]==0){
        self.courseTimeLb.hidden = NO;
        self.typeIcon.image = model.selected?[UIImage imageNamed:@"wk_vedio_s"]:[UIImage imageNamed:@"wk_vedio"];
        [self.courseTimeLb remakeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-15*ScaleX);
            make.centerY.mas_equalTo(self.contentView);
            make.size.mas_equalTo(CGSizeMake(49*ScaleX, 15*ScaleX));
        }];
        [self.typeIcon remakeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(self.courseTimeLb.mas_left).mas_equalTo(-6*ScaleX);
            make.centerY.mas_equalTo(self.contentView);
            make.size.mas_equalTo(CGSizeMake(16*ScaleX, 16*ScaleX));
        }];
    }

    self.courseTimeLb.text = model.videoLength;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
